package playn.game.level;

import org.jbox2d.callbacks.DebugDraw;

import playn.core.CanvasImage;
import playn.core.DebugDrawBox2D;
import playn.core.ImageLayer;
import static playn.core.PlayN.*;

public class JBox2dDebugger {

	public ImageLayer layer;
	
	private final static boolean showDebugDraw = true;
	
    private DebugDrawBox2D debugDraw;

	public JBox2dDebugger(int width,int height){
		layer=graphics().createImageLayer();
		CanvasImage canvasImage=graphics().createImage(width, height);
		layer.setImage(canvasImage);
		
		if(showDebugDraw) {
			debugDraw = new DebugDrawBox2D();

		    debugDraw.setCanvas(canvasImage);
		    debugDraw.setFlipY(false);
		    debugDraw.setStrokeAlpha(150);
		    debugDraw.setFillAlpha(75);
		    debugDraw.setStrokeWidth(2.0f);
		    debugDraw.setFlags(DebugDraw.e_shapeBit | DebugDraw.e_jointBit | DebugDraw.e_aabbBit);
		    debugDraw.setCamera(0, 0, 1f / Level.PIXEL_PER_METER);
		    Level.world.setDebugDraw(debugDraw);
		}
	}
}
